package com.czl.elm.controller;

import com.czl.elm.domain.RedParper;
import com.czl.elm.service.IRedParperService;
import com.czl.elm.util.ActionResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/redPaper")
public class RedParperController {

    @Autowired
    private IRedParperService redParperService;


    @ApiOperation("添加每日红包")
    @GetMapping("/addDayRedParper")
    public ActionResult addDayRedParper(){
        return redParperService.addDayRedParper();
    }


    @ApiOperation("获取所有可用红包")
    @GetMapping("/getAllRedParper")
    public ActionResult getAllRedParper(Integer currentPage,  Integer size){
        return redParperService.getAllRedParper(currentPage,size);
    }


    @ApiOperation("获取所有可用红包数量")
    @GetMapping("/getAllRedParperNumber")
    public ActionResult getAllRedParperNumber(){
        return redParperService.getAllRedParperNumber();
    }

    @ApiOperation("获取最近红包")
    @GetMapping("/getRecentRedParper")
    public ActionResult getRecentRedParper(Integer currentPage,  Integer size){
        return redParperService.getRecentRedParper(currentPage,size);
    }

    @ApiOperation("获取即将过期红包")
    @GetMapping("/getWillExpireRedParper")
    public ActionResult getWillExpireRedParper(Integer currentPage,  Integer size){
        return redParperService.getWillExpireRedParper(currentPage,size);
    }
    /**
     * 下面两个函数msg格式
     * "msg":{
     *         "shopId":1,
     *         "cost":1000,     //表示消费的金额
     *         "currentPage":1,   //当前页
     *         "size":5          //每一页的数量
     *     }
     * @return
     */
    @ApiOperation("获取商店里可用红包list")
    @GetMapping("/getUseRedParper")
    public ActionResult getUseRedParper(Integer shopId,Integer cost){
        return redParperService.getUseRedParper(shopId,cost);
    }

    @ApiOperation("获取商店里不可用红包list")
    @GetMapping("/getNoUseRedParper")
    public ActionResult getRedParper(Integer shopId,Integer cost){
        return redParperService.getNoUseRedParper(shopId,cost);
    }

    @ApiOperation("获取商店里可用红包list数量")
    @GetMapping("/getUseRedParperNumber")
    public ActionResult getUseRedParperNumber(Integer shopId,Integer cost){
        return redParperService.getUseRedParperNumber(shopId,cost);
    }

    @ApiOperation("获取商店里不可用红包list数量")
    @GetMapping("/getNoUseRedParperNumber")
    public ActionResult getRedParperNumber(Integer shopId,Integer cost){
        return redParperService.getNoUseRedParperNumber(shopId,cost);
    }

    @ApiOperation("获取历史记录的优惠券")
    @GetMapping("/getHistoryRedParper")
    public ActionResult getHistoryRedParper(Integer currentPage,  Integer size){
        return redParperService.getHistoryRedParper(currentPage,size);
    }

    @ApiOperation("今日首次登录判定")
    @GetMapping("/getFirstLoginToday")
    public ActionResult getFirstLoginToday(){
        return redParperService.getFirstLoginToday();
    }

    @ApiOperation("通过红包Id获取使用时间对象")
    @GetMapping("/getredParperByIdWithActivity")
    public ActionResult getredParperByIdWithActivity(String redParperId){
        return redParperService.getredParperByIdWithActivity(redParperId);
    }

}
